// controllers/PageController.cc
#include "PageController.h"

using namespace drogon;
using namespace drogon::orm;

void PageController::home(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    data.insert("show_title", "主页");
    setCommonViewData(req, data);
    auto resp = HttpResponse::newHttpViewResponse("home.csp", data);
    callback(resp);
}

void PageController::problem(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    data.insert("show_title", "问题");
    setCommonViewData(req, data);
    auto resp = HttpResponse::newHttpViewResponse("problem.csp", data);
    callback(resp);
}

void PageController::category(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    data.insert("show_title", "分类");
    setCommonViewData(req, data);
    auto resp = HttpResponse::newHttpViewResponse("category.csp", data);
    callback(resp);
}

void PageController::contest(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    data.insert("show_title", "比赛");
    setCommonViewData(req, data);
    auto resp = HttpResponse::newHttpViewResponse("contest.csp", data);
    callback(resp);
}

void PageController::status(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    setCommonViewData(req, data);
    data.insert("show_title", "状态");
    auto resp = HttpResponse::newHttpViewResponse("status.csp", data);
    callback(resp);
}

void PageController::ranklist(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    setCommonViewData(req, data);
    data.insert("show_title", "排名");
    auto resp = HttpResponse::newHttpViewResponse("ranklist.csp", data);
    callback(resp);
}

void PageController::knowledgeGraph(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    setCommonViewData(req, data);
    data.insert("show_title", "知识图谱");
    auto resp = HttpResponse::newHttpViewResponse("knowledge_graph.csp", data);
    callback(resp);
}

void PageController::login(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback){
    HttpViewData data;
    //setCommonViewData(req, data);
    
    auto resp = HttpResponse::newHttpViewResponse("login.csp", data);
    callback(resp);
}

void PageController::index(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    //setCommonViewData(req, data);
    auto resp = HttpResponse::newHttpViewResponse("index_.csp", data);
    callback(resp);
}

void PageController::dashboard(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) {
    HttpViewData data;
    //setCommonViewData(req, data);

    auto resp = HttpResponse::newHttpViewResponse("dashboard.csp", data);
    callback(resp);
}